#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
struct fs
{
    ll fz,fm;
};
fs operator + (fs x,fs y)
{
    ll fm=x.fm*y.fm;
    ll fz=x.fz*y.fm+x.fm*y.fz;
    ll p=__gcd(fm,fz);
    fz/=p;
    fm/=p;
    return (fs){fz,fm};
}
fs operator / (fs x,fs y)
{
    ll fz=x.fz*y.fm;
    ll fm=x.fm*y.fz;
    ll p=__gcd(fm,fz);
    fz/=p;
    fm/=p;
    return (fs){fz,fm};
}
bool operator < (fs x,fs y)
{
    ll xx=x.fz*y.fm;
    ll yy=x.fm*y.fz;
    return xx<yy;
}
bool operator == (fs x,fs y)
{
    ll xx=x.fz*y.fm;
    ll yy=x.fm*y.fz;
    return xx==yy;
}
bool operator <= (fs x,fs y)
{
    ll xx=x.fz*y.fm;
    ll yy=x.fm*y.fz;
    return xx<=yy;
}
struct pqh
{
    fs l,r;
    int k1,k2;
}c[maxn];
struct pqh2
{
    double l,r;
}d[maxn];
struct pqh3
{
    int l,r;
}f[maxn];
fs b[4*maxn];
double e[4*maxn];
ll n,m,L,V,cnt,p[maxn],cnt2,cnt3,ton[4*maxn],ans1,ton2[4*maxn],g[maxn];
vector<int>h[maxn];
void solve()
{
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    memset(d,0,sizeof(d));
    memset(e,0,sizeof(e));
    memset(f,0,sizeof(f));
    //memset(g,0,sizeof(f));
    memset(ton,0,sizeof(ton));
    memset(ton2,0,sizeof(ton2));
    ans1=cnt=cnt2=cnt3=0;
    cin>>n>>m>>L>>V;
    b[++cnt2]={L,1};
    for(int i=1;i<=n;i++)
    {
        int d,v,a;
        cin>>d>>v>>a;
        b[++cnt2]={d,1};
        if(a==0)
        {
            if(v>V)c[++cnt]={{d,1},{L,1},1,1};
        }
        else if(a<0)
        {
            if(v<=V)continue;
            fs r=(fs){V*V-v*v,1}/(fs){a+a,1}+(fs){d,1};
            if((fs){L,1}<r)c[++cnt]={{d,1},{L,1},1,1};
            else c[++cnt]={{d,1},r,1,0},b[++cnt2]=r;
        }
        else if(a>0)
        {
            if(v>V)c[++cnt]={{d,1},{L,1},1,1};
            else if(v==V)c[++cnt]={{d,1},{L,1},0,1};
            else
            {
                fs l=(fs){V*V-v*v,1}/(fs){a+a,1}+(fs){d,1};
                if((fs){L,1}<=l)continue;
                else
                {
                    c[++cnt]={l,{L,1},0,1},b[++cnt2]=l;
                }
            }
        }
    }
    for(int i=1;i<=m;i++)
    {
        h[i].clear();
        cin>>p[i];
        b[++cnt2]={p[i],1};
    }

 /*   for(int i=1;i<=cnt;i++)
    {
        cout<<c[i].l.fz<<'/'<<c[i].l.fm<<' ';
        cout<<c[i].r.fz<<'/'<<c[i].r.fm<<' ';
        cout<<c[i].k1<<' ';
        cout<<c[i].k2<<'\n';
    }
    cout<<"\n\n";*/

    sort(b+1,b+cnt2+1);
    int s=unique(b+1,b+cnt2+1)-b-1;
    for(int i=1;i<=cnt;i++)
    {
        int x=lower_bound(b+1,b+s+1,c[i].l)-b;
        int y=lower_bound(b+1,b+s+1,c[i].r)-b;
        double xx=(double)x;
        double yy=(double)y;
        if(!c[i].k1)xx+=0.5;
        if(!c[i].k2)yy-=0.5;
        d[i]={xx,yy};
        e[++cnt3]=xx;
        e[++cnt3]=yy;
    }
    for(int i=1;i<=m;i++)
    {
        int x=lower_bound(b+1,b+s+1,(fs){p[i],1})-b;
        p[i]=x;
        //cout<<x<<'\n';
        e[++cnt3]=(double)x;
    }
    sort(e+1,e+cnt3+1);
    int s2=unique(e+1,e+cnt3+1)-e-1;
    for(int i=1;i<=cnt;i++)
    {
        int x=lower_bound(e+1,e+s2+1,d[i].l)-e;
        int y=lower_bound(e+1,e+s2+1,d[i].r)-e;
        f[i]={x,y};
    }
    for(int i=1;i<=m;i++)
    {
        int x=lower_bound(e+1,e+s2+1,p[i])-e;
        p[i]=x;
        ton[x]=1;
    }
    sort(p+1,p+m+1);
    for(int i=1;i<=s2;i++)
    {
        ton[i]+=ton[i-1];
    }
    for(int i=1;i<=cnt;i++)
    {
        if(ton[f[i].r]-ton[f[i].l-1]>=1)ans1++;
    }
    //cout<<ans1<<'\n';
    priority_queue<pair<int,int> >q;
    for(int i=1;i<=n;i++)
    {
        int x=lower_bound(p+1,p+m+1,f[i].l)-p;
        int y=lower_bound(p+1,p+m+1,f[i].r)-p;
        for(int j=x;j<=y;j++)
        {
            h[j].push_back(i);
        }
    }
    for(int i=1;i<=m;i++)
    {
        q.push({h[i].size(),i});
    }
    int ans2=0;
    while(!q.empty())
    {
        int i=q.top().second;
        q.pop();
        int flag=0;
        for(int j=0;j<h[i].size();j++)
        {
            int z=h[i][j];
            //cout<<i<<' '<<z<<'\n';
            if(!ton2[z])
            {
                ton2[z]=1;
                flag=1;
            }
        }
        if(!flag)ans2++;
    }
    cout<<ans1<<' '<<ans2<<'\n';
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--)
    {
        solve();
    }
    return 0;
}
